import java.util.Scanner;

/**
 * 退休金计算
 * @version 0.1 2018-11-02
 * @author xy
 */

public class Retirement {
    public static void main(String[] args)
    {
        //获取输入扫描对象
        Scanner in = new Scanner(System.in);

        //提示语句
        System.out.println("攒够多少钱，才能提前退休？");
        System.out.println("请输入要攒的钱数：");
        float goal = in.nextFloat();

        System.out.println("请输入要存的钱的基数：");
        float payment = in.nextFloat();

        System.out.println("请输入每年存的钱增长率%：");
        float interestRate  = in.nextFloat();

        // 当前实际存下的钱数
        float balance = 0;
        int years = 0;

        //进入循环的条件：没存够钱
        while (balance<goal)
        {
            balance += payment;

            // 计算每年的增量
            float interest = balance * interestRate/100;

            balance += interest;

            years++;

            System.out.println("第"+years+"年：");
            System.out.println("当年存钱数为："+interest);
            System.out.println("总存钱数为："+balance);

        }

        System.out.println("你工作"+years+"年后就可以退休了！");
    }
}
